//
//  RegisterController.m
//  hbhy
//
//  Created by Robin on 13-6-20.
//  Copyright (c) 2013年 Robin.zhao. All rights reserved.
//

#import "RegisterController.h"

@interface RegisterController ()

@end

@implementation RegisterController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    

    UIBarButtonItem *leftBarButton = [[UIBarButtonItem alloc]
                                     initWithBarButtonSystemItem:UIBarButtonSystemItemReply
                                     target:self
                                     action:@selector(backAction)];
    
    UIBarButtonItem *rightBarButton = [[UIBarButtonItem alloc]
                                       initWithTitle:@"下一步"
                                       style:UIBarButtonItemStylePlain
                                       target:self
                                       action:@selector(nextAction)];
    self.topBarItem.leftBarButtonItem = leftBarButton;
    self.topBarItem.rightBarButtonItem = rightBarButton;
    
   
    CGRect frame = CGRectMake(25, 205,  300, 50);
    self.cbv = [[SSCheckBoxView alloc] initWithFrame:frame
                                          style:kSSCheckBoxViewStyleGlossy
                                                        checked:FALSE];
    
    [self.cbv setStateChangedTarget:self selector:@selector(declareAction)];
    [self.cbv setText:[NSString stringWithFormat:@"我已同意免费申请协议"]];
    [self.view addSubview:self.cbv];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];

}

- (void)backAction
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)nextAction
{
    UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];    
    UIViewController *next = [board instantiateViewControllerWithIdentifier:@"Proving"];
    [self presentViewController:next animated:YES completion:nil];
}

- (void)declareAction
{
    if (self.cbv.checked)
    {
        UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        UIViewController *next = [board instantiateViewControllerWithIdentifier:@"Declare"];
        [self presentViewController:next animated:YES completion:nil];
    }
}

- (void)dealloc {

    [_topBarItem release];
    [_checkBox release];
    [_accountNum release];
    [_passWord release];
    [_confirmPw release];
    [_cbv release];
    [super dealloc];
}
@end
